<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>    
<!DOCTYPE html PUBLIC>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/boardtext.css" />
<script type="text/javascript" src="./js/util.js"></script>
<script type="text/javascript">
function checkForm(f) {
	var result = true;
	if(isNull(f.title, document.getElementById("error_title"), "제목을 입력하세요!!")) result = false;
	if(isNull(f.content, document.getElementById("error_content"), "내용을 입력하세요!!")) result = false;
	return result;
}
</script>
</head>
<body>
<div id="content" align="center">
<div align="left" style= "margin: 10px 0;">
<img src = "images/board/write_tt.gif"/>
</div>
<form:form modelAttribute="board" method="post" action="save.do" onsubmit="return checkForm(this)">
<input type="hidden" name="action" value="${action}" />
<input type="hidden" name="idx" value="${board.idx}" />
<input type="hidden" name="page" value="${page}" />
<input type="hidden" name="writer" value=<%=session.getAttribute("nick_name") %>>

<div style = "border: 1px solid #D5D5D5; background:#F6F6F6; margin-bottom: 10px;">
<!-- 제목 입력폼 -->
<div id = "write_form">
	<div align="left">
		<span class = "title_1" style = "font-family: 맑은 고딕;
	font-size: 15px; font-weight: bold;color:#5D5D5D;">제목</span>
		<span class = "title_2">
		<form:input path="title" name="title" size = "130" 
		cssStyle = "text-align: left; height: 25px; margin: 10px 5px; font-family: 맑은 고딕;"/>
		</span>
		<span class="error-text" id="error_title"></span>
	</div>
</div>

<!-- 내용 입력폼 -->
<div id = "contents_form">
	<div align="left">
		<span class = "title_1" style = "font-family: 맑은 고딕;
	font-size: 15px; font-weight: bold;color:#5D5D5D;">내용</span>
		<span class = "title_2">
		<form:textarea path="content" name="content" cssStyle="width: 805px; margin:10px 5px; height:300px" /></span>
		<br/>
		<span class="error-text" id="error_content"></span>
	</div>
</div>
</div>

<div align="center" id = "btn_form">
	<input type="submit" value="확인" style = "font-family: 맑은 고딕;"  
	class = "writeBtn"/>&nbsp;
	<c:if test="${action=='update'}">
	<input class = "writeBtn" type="button" value="취소"
	style = "font-family: 맑은 고딕;" 
	onclick="location.href='view?no=${board.idx}&page=${page}&back=y'" />&nbsp;
	</c:if>
	<input class = "writeBtn" type="button" value="목록" style = "font-family: 맑은 고딕;" onclick="location.href='recommend.do?page=${page}'" />
</div>
</form:form>
</div>
</body>
</html>